package com.gem.day11;

import java.util.Arrays;

public class EnumTest {
	public static void main(String[] args) {
		Student student = new Student(1L, "张三", Gender.MALE);
		System.out.println(student);

		//获取枚举常量的名称
		System.out.println(student.getGender().name());
		//获取枚举常量的名称(可以重写)
		System.out.println(student.getGender().toString());
		//获取枚举常量下标
		System.out.println(student.getGender().ordinal());

		//把字符串转换成枚举
		//注意:转换时如果传入不匹配的枚举字符串,则转换失败: java.lang.IllegalArgumentException
		Gender g = Enum.valueOf(Gender.class, "MALE");
		System.out.println(g);

		System.out.println("-------------------------------------");

		//枚举中的
		Gender[] genders = Gender.values();
		System.out.println(Arrays.toString(genders));
	}
}
